home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Sherlock 2.0
/
DevLibSrc
/
Main_DevLib
/
LIBobj.h
< prev
next >
Wrap
Text File
|
1995-11-16
|
3KB
|
92 lines
/*
List: header file for object routines.
source: LIBobj.h
started: December 13, 1993.
version:
November 14, 1995.
`obj_free_macro' expands to `lib_free' instead of `free'.
September 25, 1995.
Removed unused title param from obj_dump_stats.
December 22, 1993.
Added obj_new_var_tag_macro.
*/
#ifndef LIBobj_h_
#define LIBobj_h_
#pragma once
/* Constants. */
#define OBJ_MAGIC 0x1234 /* Magic value for validity check. */
#define OBJ_HEADER_SIZE 4 /* Size of obj_prot field. */
#define OBJ_TRAILER_SIZE 8 /* Size of obj_trailer field. */
#define OBJ_FILLER 0xA3 /* Fill value for fields. */
/* Structures. */
typedef struct type_des_struct type_des;
typedef struct obj_head_struct obj_head;
/*
obj_new_var_tag_macro is used when the tag parameter is not a string constant.
*/
#ifdef PRODUCTION
#define obj_new_macro(the_mem, size, tag) the_mem = obj_new(size)
#define obj_new_var_tag_macro(the_mem, size, tag) the_mem = obj_new(size)
#define obj_free_macro(the_mem) lib_free(the_mem)
#else
struct type_des_struct {
char * type_name; /* Print name of this type. */
type_des * type_alpha; /* Alphabetically next type descriptor. */
obj_head * type_tlist; /* List of all object of this type. */
long type_nmax; /* Object size statistics. */
long type_nnet;
long type_ntot;
long type_cmax; /* Alloc/free (call) statistics. */
long type_cnet;
long type_ctot;
int type_attrib; /* Attributes of this type. */
int type_magic; /* Must be OBJ_MAGIC. */
};
struct obj_head_struct {
type_des * obj_type; /* Object type. */
char * obj_dtag; /* Data tag. */
obj_head * obj_olist; /* list of all objects in allocation order. */
obj_head * obj_tlist; /* list of all objects of this type. */
long obj_size; /* Size of object. (must be long!) */
char obj_prot[OBJ_HEADER_SIZE]; /* Header protection. */
};
#define obj_new_macro(the_mem, size, tag) \
{static type_des * tp_ = NULL; the_mem = obj_new_db(size, tag, &tp_);}
#define obj_new_var_tag_macro(the_mem, size, tag) \
{type_des * tp_ = NULL; the_mem = obj_new_db(size, tag, &tp_);}
#define obj_free_macro(the_mem) obj_free_db(the_mem)
#endif
/*
Function prototypes.
*/
void obj_test (void);
#ifdef PRODUCTION
void * obj_new (size_t size);
#else
void obj_check_all (void);
void obj_check_object(void *o);
void obj_dump_objects(void);
void obj_dump_stats (void);
void obj_free_db (void * obj);
void * obj_new (size_t size);
void * obj_new_db (size_t size, char * tag, type_des ** tp);
#endif
#endif /* LIBobj_h_ */